package com.ruoyi.xp.custom.controller;

import java.util.List;

import com.ruoyi.common.utils.security.PermissionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xp.custom.domain.CustomServiceTrace;
import com.ruoyi.xp.custom.service.ICustomServiceTraceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客服问题追踪记录Controller
 * 
 * @author chdx
 * @date 2022-11-30
 */
@Controller
@RequestMapping("/custom/CustomServiceTrace")
public class CustomServiceTraceController extends BaseController
{
    private String prefix = "custom/CustomServiceTrace";

    @Autowired
    private ICustomServiceTraceService customServiceTraceService;

    @RequiresPermissions("custom:CustomServiceTrace:view")
    @GetMapping()
    public String CustomServiceTrace()
    {
        return prefix + "/CustomServiceTrace";
    }

    /**
     * 查询客服问题追踪记录列表
     */
    @RequiresPermissions("custom:CustomServiceTrace:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CustomServiceTrace customServiceTrace)
    {
        startPage();
        List<CustomServiceTrace> list = customServiceTraceService.selectCustomServiceTraceList(customServiceTrace);
        return getDataTable(list);
    }

    /**
     * 导出客服问题追踪记录列表
     */
    @RequiresPermissions("custom:CustomServiceTrace:export")
    @Log(title = "客服问题追踪记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CustomServiceTrace customServiceTrace)
    {
        List<CustomServiceTrace> list = customServiceTraceService.selectCustomServiceTraceList(customServiceTrace);
        ExcelUtil<CustomServiceTrace> util = new ExcelUtil<CustomServiceTrace>(CustomServiceTrace.class);
        return util.exportExcel(list, "客服问题追踪记录数据");
    }

    /**
     * 新增客服问题追踪记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客服问题追踪记录
     */
    @RequiresPermissions("custom:CustomServiceTrace:add")
    @Log(title = "客服问题追踪记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CustomServiceTrace customServiceTrace)
    {
        return toAjax(customServiceTraceService.insertCustomServiceTrace(customServiceTrace));
    }

    /**
     * 修改客服问题追踪记录
     */
    @RequiresPermissions("custom:CustomServiceTrace:edit")
    @GetMapping("/edit/{customServiceTraceId}")
    public String edit(@PathVariable("customServiceTraceId") Long customServiceTraceId, ModelMap mmap)
    {
        CustomServiceTrace customServiceTrace = customServiceTraceService.selectCustomServiceTraceByCustomServiceTraceId(customServiceTraceId);
        mmap.put("customServiceTrace", customServiceTrace);
        return prefix + "/edit";
    }

    /**
     * 修改保存客服问题追踪记录
     */
    @RequiresPermissions("custom:CustomServiceTrace:edit")
    @Log(title = "客服问题追踪记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CustomServiceTrace customServiceTrace)
    {
        return toAjax(customServiceTraceService.updateCustomServiceTrace(customServiceTrace));
    }

    /**
     * 删除客服问题追踪记录
     */
    @RequiresPermissions("custom:CustomServiceTrace:remove")
    @Log(title = "客服问题追踪记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(customServiceTraceService.deleteCustomServiceTraceByCustomServiceTraceIds(ids));
    }
}
